<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>登录验证</title>
		<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
		<script>
			function checkUname(){
				username=$("#uname").val();
				reg=/^[a-zA-Z0-9]{3,10}$/;
				if(!reg.test(username)){
					$("#uname").css("border-color","red");
				}else{
					$("#uname").css("border-color","");
				}
			}
			function checkUpsw(){
				userpsw=$("#upsw").val();
				reg=/^[0-9]{6}$/;
				if(!reg.test(userpsw)){
					$("#upsw").css("border-color","red");
				}else{
					$("#upsw").css("border-color","");
				}
			}
			function checkAll(){
				checkUname();
				checkUpsw();
			}
		</script>
	</head>
	<body>
		<h3>用户名3到10个数字字母组合；密码6个数字</h3>
		用户名<input onblur="checkUname()" type="text" id="uname" />
		密码<input onblur="checkUpsw()" type="password" id="upsw" />
		<button onclick="checkAll()">登录</button>
	</body>
</html>
